package test;

class Message {
    private String content;
    public void setContent(String content) {
        this.content = content;
    }
    public String getContent() {
        return content;
    }
}
    class MessagePrinter {
        public static void print() {
            System.out.println("【MessagePrint】"+
                    Resource.MESSAGES.get().getContent());
        }
    }
    class Resource {
        public static final ThreadLocal<Message> MESSAGES = new ThreadLocal<Message>();
}
public class YootkDemo10 {
    public static void main(String[] args) throws Exception{
        String[] values = new String[] {"沐言科技：www.yootk.com","李华编程训练营","李华"};
        for (String msg : values) {
            new Thread(() -> {
                Resource.MESSAGES.set(new Message());
                Resource.MESSAGES.get().setContent(msg);
                MessagePrinter.print();
            }).start();
        }
    }
}
